package com.example.pets.model.entities.dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;

import com.example.pets.model.entities.User;

import java.util.List;

@Dao
public interface UserDao {
    @Query("SELECT * FROM user")
    List<User> getAll();

    @Query("SELECT * FROM user WHERE uid IN (:userIds)")
    List<User> loadAllByIds(int[] userIds);

    @Query("SELECT * FROM user WHERE uname = :uname AND password = :password")
    User findByName( String uname,  String password);

    @Query("SELECT * FROM user WHERE uname = :uname")
    List<User> findByNames( String uname);

    @Query("SELECT * FROM user WHERE email = :email")
    List<User> findByEmail( String email);

    @Insert
    void insertAll(User... users);
    @Insert(onConflict = OnConflictStrategy.IGNORE)
    long insert(User user); // 插入单个用户并返回其 row ID

    @Delete
    void delete(User user);
}
